//
//  DetailViewController.m
//  11402
//
//  Created by Clement_Gu on 16/3/10.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "DetailViewController.h"
#import "SubTableViewController.h"
@interface DetailViewController ()
@property (nonatomic,strong) UIWebView *web;
//设置属性
@property (nonatomic,strong) UIPopoverController *pop;
@property (nonatomic,strong) UIBarButtonItem *btnRight;
@property (nonatomic,strong) UILabel *labelShow;
@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    float width = [UIScreen mainScreen].bounds.size.width;
    float height = [UIScreen mainScreen].bounds.size.height;
    UIWebView *web=[[UIWebView alloc]initWithFrame:CGRectMake(0, 100, 695, 700)];
    
    self.web = web;
    [self.view addSubview:web];
    //创建label
    UILabel *labelS = [[UILabel alloc]initWithFrame:CGRectMake(0,70, 665, 30)];
    labelS.textAlignment = UITextAlignmentCenter;
    self.labelShow = labelS;
    [self.view addSubview:labelS];
    
  //导航栏barbutton 的创建
    UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc]initWithTitle:@"选择语言" style:UIBarButtonItemStylePlain target:self action:@selector(btnPress:)];
    self.navigationItem.rightBarButtonItem = rightBtn;
    self.btnRight = rightBtn;
    
    //popover的内容控制器
    SubTableViewController *tbVC = [[SubTableViewController alloc]init];
    //popover的创建
    UIPopoverController *pop = [[UIPopoverController alloc]initWithContentViewController:tbVC];
    //popover的弹出窗口设定
    pop.popoverContentSize = CGSizeMake(200, 200);
    self.pop = pop;


    
}
-(void)btnPress:(id)sender
{
    //判断popover是否弹出 并做相应的操作
    if (self.pop.popoverVisible) {
        //关闭页面
        [self.pop dismissPopoverAnimated:YES];
    }
   else
   {
       //设定弹出的位置及弹出的方向
       [self.pop presentPopoverFromBarButtonItem:self.btnRight permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
   }
}


//设置数值
-(void)setDetailUrl:(NSURL *)detailUrl
{
    _detailUrl = detailUrl;
    NSURLRequest *request=[NSURLRequest requestWithURL:detailUrl];
    [self.web loadRequest:request];
    self.labelShow.text = [NSString stringWithFormat:@"%@",detailUrl ];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
